//添加报修
function addrepair() {

    var explain = $("#explain").val();

    if (explain.trim().length < 5) {
        $("#errmsg").text("描述太短啦!");
        $('#my-alert').modal({
            relatedTarget: this,
        });
        return;
    }

    var data = {
        "owerName": $("#realName").val(),
        "mobile": $("#mobile").val(),
        "wxopenId": $("#wxopenId").val(),
        "compounds": $("#compounds").val(),
        "address": $("#address").val(),
        "repairContent": explain,
        "status": "待接单",
        "postType": "业主报修",
    }

    if ($("#img1").attr('src') != undefined && $("#img1").attr('src') != '' && $("#img1").attr('src') != '/webapp/images/add.png') {

        data["repairImg1ServerId"] = serverId1; // 返回图片的服务器端ID

        //再判断有没有第二个图
        if ($("#img2").attr('src') != undefined && $("#img2").attr('src') != '' && $("#img2").attr('src') != '/webapp/images/add.png') {

            data["repairImg2ServerId"] = serverId2;
            postData(data);

        } else {
            data["repairImg2"] = "";
            postData(data);
        }



    } else {
        data["repairImg1"] = "";
        data["repairImg2"] = "";
        postData(data);
    }


}

function postData(data) {

    $.post('/wx/property/repair/add/data', data, function(result) {

        if (result.resultCode == "0") {
            $("#errmsg").text("提交成功!");
            $('#my-alert').modal({
                relatedTarget: this,
            });
            setTimeout('location.href="javascript:history.back();"', 1000);
        } else {
            $("#errmsg").text(result.datas);
            $('#my-alert').modal({
                relatedTarget: this,
            });
            return;
        }
    });

}